<template>
  <div class="ma-content-block lg:flex justify-between p-4">
    <!-- CRUD 组件 -->
    <ma-crud :options="options" :columns="columns" ref="crudRef">
    </ma-crud>
  </div>
</template>
<script setup>
import { ref, reactive } from 'vue'
import financialSettleDetail from '@/api/financial/financialSettleDetail'
import { Message } from '@arco-design/web-vue'
import tool from '@/utils/tool'
import * as common from '@/utils/common'

const crudRef = ref()
const indexid = ref(0)

const open =  (row) => {
  indexid.value = row.user_id
  crudRef.value.refresh()
}

const numberOperation = (newValue, id, numberName) => {
  financialSettleDetail.numberOperation({ id, numberName, numberValue: newValue }).then( res => {
    res.success && Message.success(res.message)
  }).catch( e => { console.log(e) } )
}

const switchStatus = (statusValue, id, statusName) => {
  financialSettleDetail.changeStatus({ id, statusName, statusValue }).then( res => {
    res.success && Message.success(res.message)
  }).catch( e => { console.log(e) } )
}


const options = reactive({
  id: 'flyos_financial_settle_detail',
  rowSelection: {
    showCheckedAll: true
  },
  pk: 'id',
  operationColumn: true,
  operationWidth: 160,
  formOption: {
    viewType: 'modal',
    width: 600
  },
  api: financialSettleDetail.getList,
  recycleApi: financialSettleDetail.getRecycleList,
  add: {
    show: true,
    api: financialSettleDetail.save,
    auth: ['financial:settleDetail:save']
  },
  edit: {
    show: true,
    api: financialSettleDetail.update,
    auth: ['financial:settleDetail:update']
  },
  delete: {
    show: true,
    api: financialSettleDetail.deletes,
    auth: ['financial:settleDetail:delete'],
    realApi: financialSettleDetail.realDeletes,
    realAuth: ['financial:settleDetail:realDeletes']
  },
  recovery: {
    show: true,
    api: financialSettleDetail.recoverys,
    auth: ['financial:settleDetail:recovery']
  },
  import: {
    show: true,
    url: 'financial/settleDetail/import',
    templateUrl: 'financial/settleDetail/downloadTemplate',
    auth: ['financial:settleDetail:import']
  },
  export: {
    show: true,
    url: 'financial/settleDetail/export',
    auth: ['financial:settleDetail:export']
  },
  beforeRequest: (params) => {
    params.send_dept_id = indexid.value
	},
})

const columns = reactive([
  {
    title: "",
    dataIndex: "id",
    formType: "input",
    addDisplay: false,
    editDisplay: false,
    hide: true,
    commonRules: {
      required: true,
      message: "请输入"
    }
  },
  {
    title: "到达/发货时间",
    dataIndex: "cost_detail.prediction.come_time",
    formType: "input",
    search: false
  },
  {
    title: "运单号",
    dataIndex: "cost_detail.prediction.yundanhao",
    formType: "input",
  },
  {
    title: "车号",
    dataIndex: "cost_detail.prediction.car_no",
    formType: "input",
  },
  {
    title: "箱号",
    dataIndex: "cost_detail.prediction.box",
    formType: "input",
  },
  {
    title: "品名",
    dataIndex: "cost_detail.prediction.goods_name",
    formType: "input",
  },
  {
    title: "件数",
    dataIndex: "cost_detail.prediction.number",
    formType: "input",
  },
  {
    title: "货重",
    dataIndex: "cost_detail.prediction.hz_weight",
    formType: "input",
  },
  {
    title: "办理日期",
    dataIndex: "cost_detail.prediction.process_time",
    formType: "input",
  },
  {
    title: "金额",
    dataIndex: "price",
    formType: "input",
    addDisplay: false,
    editDisplay: false,
  },
  {
    title: "清算时间",
    dataIndex: "created_at",
    formType: "date",
    addDisplay: false,
    editDisplay: false,
    hide: true,
    showTime: true
  }
])
defineExpose({ open });
</script>
<script> export default { name: 'financial:settleDetail' } </script>